#!/bin/sh /etc/rc.common

START=99
USE_PROCD=1
PROG=/usr/sbin/lte

##add-by-ldg-20240711
. /lib/hclfuncs.sh

start_instance() {
  local cfg=$1
  config_get_bool enable "$cfg" enable

  if [ X$enable = X1 ]; then
    echo "starting lte"
	ifconfig wwan0 up
    procd_open_instance
    procd_set_param command "${LUALTECMD}"
    procd_set_param respawn
    procd_close_instance
  else
    echo "stoping lte"
	ifconfig wwan0 down
  fi
}

start_service() {
  uci set lteconfig.lteconfig.manufacturer=${MDMVENDOR}
  uci commit lteconfig

  config_load lteconfig
  config_foreach start_instance name lteconfig

}

stop_service() {
  #echo 0 > /sys/class/leds/pangu:blue:online/brightness  #turn off online led
  killall -s SIGTERM `basename ${LUALTECMD}` 2>/dev/null
}

reload_service() {
  stop_service
  config_load lteconfig
  config_foreach start_instance name lteconfig
}

service_triggers() {
  procd_add_reload_trigger "lteconfig"
}
